#pragma once
#include "CCommand.h"
#include <GC_MakeCylindricalSurface.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>

struct CylinderData
{
	gp_Pnt postion;
	gp_Dir direction;
	Standard_Real radius;
	Standard_Real height;
	Quantity_Color color;
};

class CylinderCommand : public BaseCommand
{
private:
	CylinderData m_data;

public:
	CylinderCommand(Handle(AIS_InteractiveContext) aisContext,
		const gp_Pnt& position,
		const gp_Dir& direction,
		Standard_Real radius,
		Standard_Real height,
		Quantity_Color color)
	{
		m_data.postion = position;
		m_data.direction = direction;
		m_data.radius = radius;
		m_data.height = height;
		m_data.color = color;

		m_aisContext = aisContext;
		m_aisObject = nullptr;
	}

	virtual bool Execute()
	{
		gp_Ax1 ax1(m_data.postion, m_data.direction);

		gp_Cylinder aCylinder(gp_Ax3(m_data.postion, m_data.direction), m_data.radius);

		BRepBuilderAPI_MakeFace aFaceMaker(aCylinder, 0, 2 * M_PI, 0, m_data.height);
		TopoDS_Face aFace = aFaceMaker.Face();

		m_aisObject = new AIS_Shape(aFace);
		m_aisObject->SetColor(m_data.color);
		m_aisContext->Display(m_aisObject, Standard_False);

		return true;
	}
};
